<?php
/**
 * Created by PhpStorm.
 * User: xpz
 * Date: 2024/1/16
 * Time: 15:39
 */

namespace app\common\model;
use think\Model;

class Geci extends Model
{
    public function getContentAttr($value, $data){
        if(!empty($data['content'])){
//            echo "3333333";
            $data['content'] = str_replace([']'],[']#'],$data['content']);
            $pattern = '/\[(.*?)\]/'; // 定义需要匹配的模式为 [ ] 之间的任意字符（非贪婪）
            $result = preg_replace($pattern, '', $data['content']); // 将匹配到的内容替换为空字符串
            $result = myTrim($result);
            $result = str_replace(['#'],['</span><span>'],$result);
            $result = "<span>".trim($result,'</span>')."</span>";
            return $result; // 输出结果为 "这是的文本"
        }
        return '';
    }
}